package com.angis.fx.activity.zdcf;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TimePicker;

import com.angis.fx.activity.R;

public class AttendanceActivity extends Activity {

	private Button mAttOKBt;
	private DatePicker mDate;
	private TimePicker mTime;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(com.angis.fx.activity.R.layout.attendance);
		mAttOKBt = (Button) findViewById(R.id.att_ok);
		mDate = (DatePicker) findViewById(R.id.att_date);
		mTime = (TimePicker) findViewById(R.id.att_time);
		mTime.setIs24HourView(true);
		mAttOKBt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				int lResult = getIntent().getExtras() == null ? 1 : getIntent().getExtras().getInt("RESULTCODE");
				Intent lIntent = new Intent();
				Bundle lBundle = new Bundle();
				Calendar lCal = Calendar.getInstance();
				lCal.set(mDate.getYear(), mDate.getMonth(), mDate.getDayOfMonth(), mTime.getCurrentHour(), mTime.getCurrentMinute(), 0);
				String lDatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(lCal.getTime());
				lBundle.putString("DATATIME", lDatetime);
				lBundle.putInt("YEAR", mDate.getYear());
				lBundle.putInt("MONTH", mDate.getMonth());
				lBundle.putInt("DAY", mDate.getDayOfMonth());
				lBundle.putInt("HOUR", mTime.getCurrentHour());
				lBundle.putInt("MINUTE", mTime.getCurrentMinute());
				lIntent.putExtras(lBundle);
				AttendanceActivity.this.setResult(lResult, lIntent);
				AttendanceActivity.this.finish();
			}
		});
	}

	
}
